package com.lm.leetcode.briefsummary;

import com.lm.leetcode.PrintUtils;

/**
 * @Auther: Min.Liu
 * @Description:
 * @Date: Created in 14:42 2025/5/20
 */
public class moveZeroesDemo {
    public static void main(String[] args) {
        moveZeroesDemo demo = new moveZeroesDemo();
        //int[] arr = {0,0,1,1,1,2,2,3,3,4};
        int[] arr = {0,1,0,3,12};
        demo.moveZeroes(arr);
        PrintUtils.printIntArray(arr);
    }

    public void moveZeroes(int[] nums) {
        int i = 0;
        int left = 0;
        while(i<nums.length){
            if (nums[i]!=0) {
                nums[left++] = nums[i];
            }
            i++;
        }
        PrintUtils.printIntArray(nums);
        for (; left < nums.length; left++) {
            if (nums[left] != 0) {
                nums[left] = 0 ;
            }
        }
    }
}
